<template>
  <!-- 重量计算方式 -->
  <div class="weightCalculation">
    <el-form ref="form" :model="form" :rules="rules">
      <el-row>
        <el-col :span="24">
          <el-form-item prop="workArea">
            <el-switch v-model="form.delivery"></el-switch>
            <span style="margin-left: 10px;">按密度计算</span>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="钢筋重量(kg)/m = 直径(mm) * 直径(mm) *" prop="workArea" label-width="300px">
            <el-input type="number" min="0" v-model="form.workArea" placeholder="请输入" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item prop="workArea">
            <el-switch v-model="form.delivery"></el-switch>
            <span style="margin-left: 10px;">按延米计算</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        v-loading="loading"
      >
        <el-table-column label="序号" width="55" align="center">
          <template slot-scope="scope">{{ scope.$index + 1 }}</template>
        </el-table-column>
        <el-table-column label="直径（mm）" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.date" placeholder="请输入内容"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="重量（kg/m）" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.name" placeholder="请输入内容"></el-input>
          </template>
        </el-table-column>
      </el-table>
      <div style="margin: 20px 0;">
        <el-button type="primary" @click="newlyBuild">添加空行</el-button>
      </div>
    </el-form>


    <div class="submitForm">
      <el-button type="primary" @click="preservation">保存</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "WeightCalculation",
  components: {},
  props: {},
  data() {
    return {
      loading: false,
      form: {},
      rules: {
        workArea: [
          { required: true, message: "不能为空", trigger: "blur" },
        ],
      },
      tableData: [
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          value: '0',
        },
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          value: '0',
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          value: '0',
        },
      ],
    };
  },
  filters: {},
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  beforeDestroy() {},
  methods: {
    newlyBuild() {
      console.log('新建')
      this.tableData.push(
        {
          date: "",
          name: "",
          address: "",
          value: '',
        }
      )
    },
    resetPassword(val) {
      console.log(val)
    },
    preservation() {
      console.log(this.tableData)
    }
  },
};
</script>

<style scoped lang="scss">
.weightCalculation {
  width: 50%;
}
</style>
